<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>流转记录</title>
	<script src="../scripts/boot.js" type="text/javascript"></script>
	<style type="text/css">
		html,body {
			margin: 0;
			padding: 0;
			border: 0;
			width: 100%;
			height: 100%;
		}
		.mini-panel-header-inner{font-size:14px; }
	</style>
</head>

<body>
<div class="mini-splitter" style="width:100%;height:100%;">
	<div size="240" showCollapseButton="true">
		<div class="mini-fit">
			<div class="mini-panel" title="组织架构" style="width:100%;height:100%;"
				 showToolbar="true" showCloseButton="false" showFooter="true"
			>
				<ul id="tree1" class="mini-tree" url="getOrganization" style="width:100%;"
					showTreeIcon="true" textField="name" idField="uid" parentField="sid" resultAsTree="false">
				</ul>
			</div>
		</div>
	</div>
	<div showCollapseButton="true">
		<div class="mini-toolbar">
			<a class="mini-button" plain="true" onclick="detail" iconcls="icon-node">查看详情</a>
		</div>
		<div class="mini-fit"><!-- onrowdblclick="edit" 双击事件 -->
			<div id="datagrid1" class="mini-datagrid" allowResize="false" pageSize="20" url="listData"
				 style="width:100%;height:100%;" borderStyle="border-top:none;" idField="id" multiSelect="true"
			>
				<div property="columns">
					<div field="name" width="100" headerAlign="center" align="center" allowSort="false">姓名</div>
					<div field="sex" width="50" headerAlign="center" align="center" allowSort="false">性别</div>
					<div field="personId" width="100" headerAlign="center" align="center" allowSort="false">身份证号</div>
					<div field="partyDate" width="100" headerAlign="center" align="center" allowSort="false">入党时间</div>
					<div field="nativePlace" width="100" headerAlign="center" align="center" allowSort="false">籍贯</div>
					<div field="workUnitAndPosition" width="200" headerAlign="center" align="center" allowSort="false">工作单位及职务</div>
					<div field="dutyLevel" width="100" headerAlign="center" align="center" allowSort="false">职级</div>
					<div field="dutyDate" width="100" headerAlign="center" align="center" allowSort="false">任职时间</div>
					<div field="leadingPosition" width="100" headerAlign="center" align="center" allowSort="false">职务层次</div>
					<div field="leadingDate" width="100" headerAlign="center" align="center" allowSort="false">任职务时间</div>
					<div field="eduFullTimeLevel" width="100" headerAlign="center" align="center" allowSort="false">全日制教育等级</div>
					<div field="workUnitName" width="100" headerAlign="center" align="center" allowSort="false">工作单位</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var basepath = window.location.pathname + "/../";
	//初始化
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.load();

	//树
	var tree = mini.get("tree1");
	tree.on("nodeselect", function (e) {
		console.log(e);
		grid.load({ orgUid: e.node.uid });
	});

	function exchangeCaseType(e){
		var caseType = e.row.caseType;
		if(caseType == '1'){
			return "民事案件";
		}else if(caseType == '2'){
			return "刑事案件";
		}else if(caseType == '3'){
			return "执行案件";
		}else{
			return "";
		}
	}

	function isOverdueStatus(e){
		var status = e.row.status;
		if(status == '1'){
			return "<span style='color:lightskyblue;'>进行中</span>";
		}else if(status == '2'){
			return "<span style='color:#18a689;'>已完成</span>";
		}else if(status == '3'){
			return "<span style='color:#ff0000;'>已逾期</span>";
		}else{
			return "";
		}
	}

	//编辑
	function detail() {
		var row = grid.getSelected();
		if(row == null){
			mini.alert("请选择一条记录");
			return;
		}
		mini.open({
			url : basepath+"detail?id="+row.id,
			title : "编辑报名清单",
			width : 1200,
			height : 700,
			allowResize: false,
			onload : function() {
				var iframe = this.getIFrameEl();
				iframe.contentWindow.SetData(row);
			},
			ondestroy : function(action) {
				if (action == "save") {
					grid.reload();
				}
			}
		});
	}
	//编辑
	function edit() {
		var row = grid.getSelected();
		if(row == null){
			mini.alert("请选择一条记录");
			return;
		}
		mini.open({
			url : basepath+"edit",
			title : "编辑报名清单",
			width : 800,
			height : 292,
			allowResize: false,
			onload : function() {
				var iframe = this.getIFrameEl();
				iframe.contentWindow.SetData(row);
			},
			ondestroy : function(action) {
				if (action == "save") {
					grid.reload();
				}
			}
		});
	}
	//删除
	function remove() {
		var rows = grid.getSelecteds();
		if(rows == null || rows.length<=0){
			mini.alert("请选择一条记录");
			return;
		}
		mini.showMessageBox({
			title: "提示",
			width: 250,
			buttons: ["ok", "cancel"],
			message: "确认删除选中的记录吗？",
			iconCls: "mini-messagebox-question",
			callback: function (action) {
				if (action == "ok") {
					executeRemove(rows);
				}
			}
		});
	}
	//执行删除
	function executeRemove(rows){
		var ids = [];
		for ( var i = 0, l = rows.length; i < l; i++) {
			var r = rows[i];
			ids.push(r.id);
		}
		var id = ids.join(',');
		mini.mask({
			el: document.body,
			cls: 'mini-mask-loading',
			html: '正在处理，请耐心等待 ...'
		});

		$.ajax({
			url : "delete",
			type : "post",
			data : {
				ids : id
			},
			success : function(text) {
				mini.unmask();
				var result = mini.decode(text);
				if (result.res) {
					grid.reload();
				} else {
					mini.showMessageBox({
						title : "提示",
						width : 250,
						buttons : ["ok"],
						iconCls : "mini-messagebox-warning",
						message : result.msg
					});
				}
			},
			error : function(jqXHR, textStatus, errorThrown) {
				mini.unmask();
				alert(jqXHR.responseText);
			}
		});
	}
	//流转
	function gonext() {
		mini.open({
			url : basepath+"gonext",
			title : "案件流转",
			width : 800,
			height : 360,
			allowResize: false,
			onload : function() {

			},
			ondestroy : function(action) {
				if (action == "save") {
					grid.reload();
				}
			}
		});
	}
	//筛选
	function search(){
		mini.open({
			url : basepath+"search",
			title : "筛选",
			width : 800,
			height : 500,
			allowResize : false,
			ondestroy : function (action) {
				if(action == "search"){
					var iframe = this.getIFrameEl();
					var data = iframe.contentWindow.GetData();
					console.log(data);
					data = mini.clone(data);
					grid.load(data);
				}
			}
		});
	}
	//导入Excel
	function importExcel() {
		mini.open({
			url : basepath+"import",
			title : "导入 - 【请将数据放到EXCEL文件第一个工作表中】",
			width : 400,
			height : 200,
			allowResize : false,
			ondestroy : function (action) {
				if(action='ok'){
					grid.reload();
				}
			}
		});
	}


	//导出Excel
	function exportExcel(){
		mini.confirm("确定导出记录？", "导出",
				function (action) {
					if (action == "ok") {
						executeExport();
					} else {
					}
				}
		);
	}
	//执行导出
	function executeExport(){
		var data = grid.getLoadParams();
		mini.mask({
			el: document.body,
			cls: 'mini-mask-loading',
			html: '正在导出...'
		});
		$.ajax({
			url : "export",
			type : "post",
			data : data,
			dataType : "json",
			success : function(resultBean) {
				mini.unmask();
				if(resultBean.res){
					window.location.href = resultBean.data;
				}else{
					mini.alert(resultBean.msg);
				}
			},
			error : function(redata) {
				mini.unmask();
			}
		});
	}
</script>
</body>
</html>
